package com.ujs.edu.demo.dao;

import com.ujs.edu.demo.dataobject.BcAdmin;
import org.apache.ibatis.jdbc.SQL;

public class AdminBuildQuery {
    public String QueryBuiler(BcAdmin bcAdmin){
        return new SQL(){
            {
                SELECT("admin_id, username, password, email, realname, sex, mobile, createtime, modifytime, role_id");
                FROM("bc_admin");
                if(bcAdmin.getEmail()!=null){
                    WHERE("email=#{bcAdmin.email}");
                }else if (bcAdmin.getMobile()!=null){
                    WHERE("mobile=#{bcAdmin.mobile}");
                }else if (bcAdmin.getUsername()!=null){
                    WHERE("username=#{bcAdmin.username}");
                }
            }
        }.toString();
    }
}
